package org.geek4j.solr.repository;

import org.geek4j.solr.model.Item;
import org.springframework.data.domain.Pageable;
import org.springframework.data.solr.core.query.result.FacetPage;
import org.springframework.data.solr.core.query.result.HighlightPage;
import org.springframework.data.solr.repository.Facet;
import org.springframework.data.solr.repository.Highlight;
import org.springframework.data.solr.repository.Query;
import org.springframework.data.solr.repository.SolrCrudRepository;
import org.springframework.stereotype.Repository;

/**
 * 
 * @author Geek4J
 *
 * @Description Item repository
 */
@Repository
public interface ItemRepository extends SolrCrudRepository<Item, String> {

	@Highlight(prefix = "<b>", postfix = "</b>")
	HighlightPage<Item> findByName(String name, Pageable page);

	@Highlight(prefix = "<b>", postfix = "</b>")
	@Query("name:?0")
	HighlightPage<Item> findByNameLike(String name, Pageable page);

	@Facet(fields = "name")
	FacetPage<Item> findByNameStartsWith(String name, Pageable page);

}